﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace GFC
{
    [Serializable]
    [XmlInclude(typeof(PersistentField))]
    [XmlInclude(typeof(ConditionalField))]
    public abstract class Field
    {
        protected Frame m_Frame;
        protected string m_Name;
        protected int m_Size;
        protected FieldType m_Type;

        protected Field()
        {
        }

        public Field(Frame frame, string name, int size, FieldType type)
        {
            this.m_Frame = frame;
            this.m_Name = name;
            this.m_Size = size;
            this.m_Type = type;
        }

        [XmlIgnore]
        public Frame Frame
        {
            get { return m_Frame; }
            set { m_Frame = value; }
        }

        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }

        public int Size
        {
            get { return m_Size; }
            set { m_Size = value; }
        }

        public FieldType Type
        {
            get { return m_Type; }
            set { m_Type = value; }
        }

        public override bool Equals(object obj)
        {
            Field field = obj as Field;
            if (field == null)
                return false;
            return (this.Name == field.Name && this.Size == field.Size && this.Type.Equals(field.Type));
        }
    }
}
